﻿using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Portal.Web.Global;
using Portal.Db.Service;
using Portal.Core;
using Portal.Utilities;
using Portal.Web.Framework;
using Portal.AssetTn.Model;
using Portal.Ws.Utilities.Ws;
using Portal.Ws.Utilities;
using System.IO;

namespace Portal.Gui.Web.WebParts.AssetTn
{
    public class AssetNationalBll
    {
        public AssetNationalCls[] ReadingAssetNational(string SiteId, string Keyword)
        {
            SiteParam oSiteParam = Environments.CreateSiteParam(SiteId);
            WsInParam oWsInParam = WebServiceUtility.CreateWsInParam(oSiteParam, "Portal.Ws.AssetTn.Bussiness.dll", "ReadingAssetNational");
            oWsInParam.Keyword=Keyword;
            WsOutParam outParam = UtilitiesBll.ProcessCommand(SiteId, oWsInParam);
            AssetNationalCls[] AssetNational = AssetNationalParser.ParseMultiRecordFromXml(outParam.XmlData);
            if (AssetNational == null) AssetNational = new AssetNationalCls[0];
            return AssetNational;
        }



        public AssetNationalCls CreateAssetNationalModel(string SiteId, string AssetNationalId)
        {
            SiteParam oSiteParam = Environments.CreateSiteParam(SiteId);
            WsInParam oWsInParam = WebServiceUtility.CreateWsInParam(oSiteParam, "Portal.Ws.AssetTn.Bussiness.dll", "CreateAssetNationalModel");
            oWsInParam.KeyId = AssetNationalId;
            WsOutParam outParam = UtilitiesBll.ProcessCommand(SiteId, oWsInParam);
            AssetNationalCls OAssetNational = AssetNationalParser.ParseFromXml(outParam.XmlData);
            return OAssetNational;
        }


        public void SaveAssetNational(string SiteId, string AssetNationalId, AssetNationalCls OAssetNational)
        {
            SiteParam oSiteParam = Environments.CreateSiteParam(SiteId);
            WsInParam oWsInParam = WebServiceUtility.CreateWsInParam(oSiteParam, "Portal.Ws.AssetTn.Bussiness.dll", "SaveAssetNational");
            oWsInParam.KeyId = AssetNationalId;
            oWsInParam.XmlData = AssetNationalParser.GetXml(OAssetNational);
            UtilitiesBll.ProcessCommand(SiteId, oWsInParam);
        }


        public void AddAssetNational(string SiteId, AssetNationalCls OAssetNational)
        {
            SiteParam oSiteParam = Environments.CreateSiteParam(SiteId);
            WsInParam oWsInParam = WebServiceUtility.CreateWsInParam(oSiteParam, "Portal.Ws.AssetTn.Bussiness.dll", "AddAssetNational");
            oWsInParam.XmlData = AssetNationalParser.GetXml(OAssetNational);
            UtilitiesBll.ProcessCommand(SiteId, oWsInParam);
        }


        public void DeleteAssetNational(string SiteId, string AssetNationalId)
        {
            SiteParam oSiteParam = Environments.CreateSiteParam(SiteId);
            WsInParam oWsInParam = WebServiceUtility.CreateWsInParam(oSiteParam, "Portal.Ws.AssetTn.Bussiness.dll", "DeleteAssetNational");
            oWsInParam.KeyId = AssetNationalId;
            UtilitiesBll.ProcessCommand(SiteId, oWsInParam);
        }
    }
}
